package cn.org.eshow.service.impl;

import cn.org.eshow.bean.query.ProductCommentQuery;
import cn.org.eshow.common.page.Page;
import cn.org.eshow.dao.ProductCommentDao;
import cn.org.eshow.model.ProductComment;
import cn.org.eshow.service.ProductCommentManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.jws.WebService;
import java.util.List;

@WebService(serviceName = "ProductCommentService", endpointInterface = "cn.org.eshow.service.ProductCommentManager")
@Service
public class ProductCommentManagerImpl extends GenericManagerImpl<ProductComment, Integer> implements ProductCommentManager {

	@Autowired
	ProductCommentDao productCommentDao;

	public ProductCommentManagerImpl() {
	}

	@Autowired
	public ProductCommentManagerImpl(ProductCommentDao productCommentDao) {
		super(productCommentDao);
		this.productCommentDao = productCommentDao;
	}

	@Override
	public List<ProductComment> list(ProductCommentQuery query) {
		return productCommentDao.list(query);
	}

	@Override
	public Page<ProductComment> search(ProductCommentQuery query) {
		return productCommentDao.search(query);
	}

	@Override
	public ProductComment check(ProductCommentQuery query) {
		List<ProductComment> list = productCommentDao.list(query);
		if (!list.isEmpty()) {
			return list.get(0);
		}
		return null;
	}

	@Override
	public Long count(ProductCommentQuery query){
		return productCommentDao.count(query);
	}

}